<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue组件数传递prop</title>
</head>

<body>
    <div id="app">
        {{msg}}
        <button @click="updateImgUrl">修改图片</button>
        <button @click="updateUserName">修改用户名</button>
        <welcome :img-url="imgUrl" :user-name="userName"></welcome>
    </div>
    <!-- 欢迎组件 -->
    <template id="welcome">
        <div>
            <div>
                <img :src="imgUrl" alt="" style="width: 200px;">
            </div>
            <div>
                欢迎光临：{{userName}}
            </div>
        </div>
    </template>
</body>

</html>srr
<script type="module">
    import { } from './js/vue.js'
    //欢迎组件
    let welcome = {
        template: '#welcome',
        props: {
            imgUrl: String,
            userName: String,
        },
    }
    let app = new Vue({
        el: '#app',
        data: {
            msg: 'vue组件数传递prop',
            imgUrl: './imgs/OIP-A.jpg',
            userName: '李四'
        },
        methods: {
            updateImgUrl() {
                this.imgUrl = './imgs/OIP-C.jpg'
            },
            updateUserName() {
                this.userName = '王五'
            }
        },
        components: {
            welcome,
        }
    })
</script>